import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import '@/assets/css/global.css'
Vue.config.productionTip = false
import TreeTable from 'vue-table-with-tree-grid'
//导入富文本编译器
import VueQuillEditor from 'vue-quill-editor'
// 富文本编译器样式require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
//导入axios
import axios from 'axios'
//配置请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//- 需要授权的 API ，必须在请求头中使用 `Authorization` 字段提供 `token` 令牌
// axios请求拦截
axios.interceptors.request.use(config => {
  // 为请求头对象，添加 Token 验证的 Authorization 字段
  // console.log(config)
    config.headers.Authorization = window.sessionStorage.getItem('token')
    return config
  },
  error => {
      return Promise.reject(error);
  })
//设置$http
Vue.component('tree-table', TreeTable)
//注册富文本编译器
Vue.use(VueQuillEditor)
Vue.filter('dataFormat',function(originValue){
      const dt = new Date(originValue)
      const y =  dt.getFullYear()
      const m =  (dt.getMonth() + 1 + '').padStart(2,'0')
      const d =  (dt.getDay() + '').padStart(2,'0')

      const hh = (dt.getHours()+ '').padStart(2,'0')
      const mm = (dt.getMinutes()+ '').padStart(2,'0')
      const ss = (dt.getSeconds()+ '').padStart(2,'0')
      return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
Vue.prototype.$http = axios
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
